import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store ({
    state: {
        count: 0
    },
    mutations: {
        increment (state) {
            state.count++
        }
    },
    getters: {
        doubleCount: state => {
            return state.count * 2;
        }
    },
    actions:{
        asyncIncrement:({commit}) => {
            setTimeout(() => {
                commit('increment');
            }, 2000);
        }
    }
})
